<?php

class Admin_Model_DbTable_LessionTest extends Zend_Db_Table_Abstract
{

    protected $_name = 'lession_test';

    public function getAllLession(){
    	return $this->fetchAll();
    }
    
    public function getLessionByID($lessionID){
    	return $this->fetchRow("lession_test_id = $lessionID");
    }
    
    public function addLessionTest($stdID,$lessionID,$teacherID,$lessionLibTestID,$lessionTestContent,$lessionTestAnswer,$mark,$auto){
    	$data = array(
    			"student_id"=>$stdID,
    			"lession_id"=>$lessionID,
    			"teacher_id"=>$teacherID,
    			"lession_libs_test_id"=>$lessionLibTestID,
    			"lession_test_content"=>$lessionTestContent,
    			"lession_test_answer"=>$lessionTestAnswer,
    			"mark"=>$mark,
    			"auto"=>$auto,
    			"status"=>0
    			);
    	return $this->insert($data);
    }
    
    public function updateLessionTest($lessionTestID,$stdID,$lessionID,$teacherID,$lessionLibTestID,$lessionTestContent,$lessionTestAnswer,$mark,$auto){
    	$data = array(
    			"student_id"=>$stdID,
    			"lession_id"=>$lessionID,
    			"teacher_id"=>$teacherID,
    			"lession_libs_test_id"=>$lessionLibTestID,
    			"lession_test_content"=>$lessionTestContent,
    			"lession_test_answer"=>$lessionTestAnswer,
    			"mark"=>$mark,
    			"auto"=>$auto,
    			"status"=>0
    			);
    	return $this->update($data, "lession_test_id = $lessionTestID");
    }

}

